package com.henry.chatkit.messages

import android.net.Uri
import com.henry.chatkit.MessageStatus
import com.henry.chatkit.MessageType
import java.util.*

class MessageInfo(type: Int = MessageType.NONE, isSelf: Boolean = false) {

    var id = UUID.randomUUID().toString()

    var msgType = type
    // 非文字消息在会话列表时展示的文字说明，比如照片在会话列表展示为“[图片]”
    var extra = ""
    // 毫秒
    var msgTime: Long = 0
    var showTime: Boolean = false

    var isSelf = isSelf
    var isGroup: Boolean = false

    var fromUserId: String? = ""
    var fromUserName: String? = ""
    var fromUserIcon: String? = ""

    var status = MessageStatus.NORMAL
    var read: Boolean = false

    // 文本
    var text = ""

    // 图片
    var imgWidth = 40
    var imgHeight = 40
    var url = ""
    var thumbUrl = ""

    // 多媒体
    var uri: Uri? = null
    // 本地路径
    var path = ""

    // 语音 秒
    var duration = 0

    // 自定义数据 JSON字符串
    var data = ""

    fun getDisplay(): String {
        return when (msgType) {
            MessageType.TEXT -> text
            MessageType.IMAGE -> "[图片]"
            MessageType.AUDIO -> "[语音]"
            MessageType.VIDEO -> "[视频]"
            MessageType.FILE -> "[文件]"
            MessageType.LOCATION -> "[位置]"
            MessageType.CUSTOM_FACE -> "[表情]"
            MessageType.CUSTOM -> "[自定义]"
            MessageType.VOTE -> "[投票]"
            MessageType.SYSTEM -> text
            else -> ""
        }
    }

}